package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"
	"time"
)

// User holds the schema definition for the User entity.
type User struct {
	ent.Schema
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.String("username").
			Unique().
			NotEmpty().
			Comment("登录账号"),
		field.String("password").
			NotEmpty().
			Sensitive().
			Comment("密码"),
		field.String("display_name").
			NotEmpty().
			Comment("显示名称"),
		field.String("avatar").
			Optional().
			Comment("头像URL"),
		field.Time("created_at").
			Default(time.Now).
			Immutable().
			Comment("创建时间"),
		field.Time("updated_at").
			Default(time.Now).
			UpdateDefault(time.Now).
			Comment("更新时间"),
	}
}

// Edges of the User.
func (User) Edges() []ent.Edge {
	return []ent.Edge{
		edge.To("schedules", Schedule.Type),
		edge.To("countdowns", Countdown.Type),
		edge.To("bottles", Bottle.Type),
		edge.To("daily_checkins", DailyCheckin.Type),
		edge.To("sent_notes", Note.Type),
		edge.To("received_notes", Note.Type),
		edge.To("photos", Photo.Type),
		edge.To("wishes", Wish.Type),
		edge.To("media_records", MediaRecord.Type),
		edge.To("sent_gifts", Gift.Type),
		edge.To("received_gifts", Gift.Type),
	}
}
